<template>
	<view>
		<index v-if="index==0" @todraw="todraw"></index>
		<draw  :drawtype='drawtype' v-if="index==1&&showdraw"></draw>
		<fastSeller v-if="index==3"></fastSeller>
		<user v-if="index==4"></user>
	 	<foo-bar @toIndex="toIndex"  :home='index' :type="1"></foo-bar>
	</view>
</template>

<script>
	import fooBar from '../../components/yx-bottomBar/yx-bottomBar'
	import draw from '../draw/draw'
	import fastSeller from '../fastSeller/fastSeller'
	import user from '../user/user'
	import index from '../index/index'
	export default {
		components: {
			fooBar,
			index,
			fastSeller,
			user,
			draw
		},
		data() {
			return {
				index: 0,
				drawtype:1,//1、普通抽奖 2终极抽奖
				showdraw:1,
			}
		},
		created(e) {
			console.log(e)
		},
		onLoad(e) {
			if(e.index){
				this.index=parseInt(e.index)
			}
		},
		methods:{
			//切换页面
			toIndex(e){
				console.log(e)
				uni.pageScrollTo({
					scrollTop:0
				})
				if(e!=2){
					uni.setStorageSync('drawtype',1)
					this.index=e
				}
				if(e==1){
					uni.showLoading({
						title:'加载中'
					})
					this.showdraw=0
					setTimeout(()=>{
						uni.hideLoading()
						this.index=e
						this.showdraw=1
						this.drawtype=1
					},100)
					
				
					// 点击抽奖页面重置当前抽奖状态
					// this.todraw({index:1,drawtype:1})
				}
			},
			// 首页切换至抽奖页面
			todraw(e){
				uni.pageScrollTo({
					scrollTop:0
				})
				this.index=e.index
				this.drawtype=e.drawtype
			}
		}
	}
</script>

<style lang="less">
.line{
	height: 168rpx;
}
</style>
